package com.ygqh.baby.service;

import com.ygqh.baby.ao.*;
import com.ygqh.baby.constant.Constant;
import com.ygqh.baby.model.YgPromotionItemModel;
import com.ygqh.baby.model.YgPromotionModel;
import com.ygqh.baby.po.YgPromotion;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

public interface YgPromotionService {
    /**
     * @param supplierId 商家id
     * @param pStatus    促销活动状态（未开始，进行中，已结束）
     * @param pType      促销类型
     * @param startDate  活动开始日期
     * @param endDate    活动结束日期
     * @param q          q
     * @return List<YgPromotion>
     */
    List<YgPromotion> find(Long supplierId, PromotionStatus pStatus, PromotionType pType, Date startDate, Date endDate, String q);

    /**
     * @param queryInfo  分页
     * @param supplierId 商家id
     * @param pStatus    促销活动状态（未开始，进行中，已结束）
     * @param pType      促销类型
     * @param startDate  活动开始日期
     * @param endDate    活动结束日期
     * @param q          q
     * @return ResultSet<YgPromotion>
     */
    ResultSet<YgPromotion> search(QueryInfo queryInfo, Long supplierId, PromotionStatus pStatus, PromotionType pType, Date startDate, Date endDate, String q);

    int findCount();

    YgPromotion findById(Long id);

    int deleteSoft(Long[] ids);

    int deleteSoft(Long id);

    /**
     */
    Message addPromotion(Long supplierId, String promotionTitle, PromotionType promotionType, BigDecimal limitPrice, BigDecimal discountPrice,
                         String productCodes, Boolean useCoupon, String remark, Date startDate, Date endDate, String createBy, String platformNo);

    String addPromotionProduct(PromotionType promotionType, String productCodes, String handler);

    /**
     * 更新促销商品
     */
    int updatePromotion(Long promotionId, String promotionTitle, PromotionType promotionType, BigDecimal limitPrice, BigDecimal discountPrice,
                        String productCodes, Boolean useCoupon, String remark, Date startDate, Date endDate, String updateBy, String platformNo);

    /**
     * 获取满足条件促销
     */
    @Deprecated
    List<YgPromotionItemModel> findPromotionItemList(PromotionType pType, BigDecimal limitPrice);

    List<YgPromotionItemModel> findPromotionItemList(PromotionType pType, BigDecimal limitPrice, SalesPlatform salesPlatform);

    /**
     * 根据productId查询促销(订单检验使用)
     */
    @Deprecated
    List<YgPromotion> findPromotionBySkuId(Long skuId, PromotionType pType, BigDecimal limitPrice);

    List<YgPromotion> findPromotionBySkuId(Long skuId, PromotionType pType, BigDecimal limitPrice, SalesPlatform salesPlatform);

    /**
     * 获取拥有的促销信息
     */
    @Deprecated
    List<YgPromotionModel> findOwnPromotionList(PromotionType pType);

    List<YgPromotionModel> findOwnPromotionList(PromotionType pType, SalesPlatform salesPlatform);

    @Deprecated
    List<YgPromotionModel> findJiajiagoPromotionList(Long productId);

    List<YgPromotionModel> findJiajiagoPromotionList(Long productId, SalesPlatform salesPlatform);

    @Deprecated
    List<YgPromotionModel> findManZengPromotionList(Long productId);

    List<YgPromotionModel> findManZengPromotionList(Long productId, SalesPlatform salesPlatform);

    @Deprecated
    Map<String, Object> findOwnPromotionListNotLogin(Long productId, Long brandId);

    Map<String, Object> findOwnPromotionListNotLogin(Long productId, Long brandId, SalesPlatform salesPlatform);

    void setManFanCoupon(BigDecimal limitPrice, String couponBatchIds);

    Map getManFanCoupon();

    void delManFanCoupon();


    default String[] getPlatformNos(SalesPlatform salesPlatform) {
        if (SalesPlatform.Yijiadian.equals(salesPlatform)) {
            return new String[]{"All", Constant.YIJIADIAN_PLATFORM_NO};
        } else if (SalesPlatform.Yiigoo.equals(salesPlatform)) {
            return new String[]{"All", Constant.YIIGOO_PLATFORM_NO};
        } else {
            return new String[]{"All"};
        }
    }

    default String getPlatformNo(SalesPlatform salesPlatform) {
        if (SalesPlatform.Yiigoo.equals(salesPlatform)) {
            return Constant.YIIGOO_PLATFORM_NO;
        } else if (SalesPlatform.Yijiadian.equals(salesPlatform)) {
            return Constant.YIJIADIAN_PLATFORM_NO;
        } else {
            return SalesPlatform.All.name();
        }
    }
}
